#!/bin/bash

# Define the external interface variable
INTERFACE="enp2s0f0np0"

echo "Configuring IPtables FORWARD chain for external interface: ${INTERFACE}"

#Allow new connections from 192.168.1.0/24 into the 192.168.122.0/24 network
sudo iptables -I FORWARD 1 -s 192.168.1.0/24 -d 192.168.122.0/24 -j ACCEPT

# Allow return traffic (already mostly covered by RELATED,ESTABLISHED, but good to be explicit)
sudo iptables -I FORWARD 1 -s 192.168.122.0/24 -d 192.168.1.0/24 -j ACCEPT

sudo service netfilter-persistent save

echo "IPtables forwarding rules configured and saved."

